Helpful Information
 
 
Category: Scheduled Task
Scheduled Task > Batch File > PHP Script

I'm trying to run a PHP script through a Windows scheduled task. I set up a batch file reading:

c:\php\php.exe cron.php
'cron.php' being the script I want to run in the task.

The script works in a browser but gives me errors when I see it run in the console. All the script does is connect to a database delete some records from temp databases and writes a log file. The log files write but it never connects to the database. It yells 'Unable to connect to XXX.XXX.XXX.XXX on line XX. Why would it work in the browser, but not the batch file?

Yes?

do you have mysql (assuming you are using mysql) running when the task is run?

chmod file list

explain countries & tables

does your script rely on any server variables , eg $_SERVER['PHP_SELF'] , $_SERVER['DOCUMENT_ROOT'] etc ?
or $_GET or $_POST data ?? remember these are not always available in the CGI binary
(some $_SERVER variables are in the cli binary though I think)

if you want to pass any variables to the script use $argc & $argv variables
.. /path/to/script.php arg1 arg2 arg3

Its MSSQL and no I don't pass any arguments to the script. It's all runs internally.










privacy (GDPR)